package com.revenant.driver.adapter.Driver;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.revenant.driver.R;
import com.revenant.driver.bean.AreaShowBean;
import com.revenant.driver.bean.Driver.PingTaiBean;

import java.util.Arrays;
import java.util.List;

/**
 * @ProjectName: Shipper
 * @Package: com.revenant.shipper.adapter
 * @ClassName: MineBigItemAdapter
 * @Description: java类作用描述
 * @Author: revenant
 * @CreateDate: 2019-12-30 14:18
 * @UpdateUser: 更新者
 * @UpdateDate: 2019-12-30 14:18
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class PingTaiAdapter extends BaseQuickAdapter<PingTaiBean.DataBean.ResultBean, BaseViewHolder> {

    public PingTaiAdapter() {
        super(R.layout.item_shipper_published);
    }

    List<String> danwei = Arrays.asList("吨", "方", "米", "件");

    @Override
    protected void convert(BaseViewHolder helper, PingTaiBean.DataBean.ResultBean item) {
        helper.setText(R.id.start_place, item.getLoading());
        helper.setText(R.id.end_place, item.getUnload());
        if (item.isIsOnline()) {
            helper.setText(R.id.onoroff, "线下");
        } else {
            helper.setText(R.id.onoroff, "线上");
        }


        Double aweight = Double.valueOf(item.getWeight());
        String resultweight = String.format("%.0f", aweight);


        Double aprice = Double.valueOf(item.getPrice());
        String resultprice = String.format("%.0f", aprice);

        if (item.getDanWei()>0&&item.getDanWei()<5){
            helper.setText(R.id.type_and_weight, item.getVehicleLeader() + "|" + String.valueOf(resultweight) + danwei.get(item.getDanWei() - 1));

        }else {
            helper.setText(R.id.type_and_weight, item.getVehicleLeader() + "|" + String.valueOf(resultweight) + danwei.get(0));

        }

        helper.setText(R.id.price_published, "预估价:" + String.valueOf(resultprice));
        helper.setText(R.id.time_published, String.valueOf(item.getCtime()));
        if (item.isIsAuto()) {
            helper.setText(R.id.isauto_confirm, "手动确认");
        } else {
            helper.setText(R.id.isauto_confirm, "自动确认");
        }
        helper.setText(R.id.companyName, item.getCompanyName());
        helper.setText(R.id.shengyu, "剩" + String.valueOf(item.getTotal()) + "辆");

        helper.setGone(R.id.click_phone, true);
        helper.addOnClickListener(R.id.click_phone);

    }
}
